﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Services
{
    public class MobileCourseModel : ModelBase
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid? Id { get; set; }

        /// <summary>
        /// 课程名称
        /// </summary>
        public string? CourseName { get; set; }

        /// <summary>
        /// 课程分类Id
        /// </summary>
        public Guid? CourseTypeId { get; set; }
        /// <summary>
        /// 课程分类
        /// </summary>
        public string? CourseTypeStr { get; set; }

        /// <summary>
        /// 讲师id
        /// </summary>
        public Guid? LecturerId { get; set; }
        /// <summary>
        /// 讲师名
        /// </summary>
        public string? LecturerName { get; set; }

        /// <summary>
        /// 课程分类
        /// </summary>
        public virtual CourseType? CourseType { get; set; }

        /// <summary>
        /// 讲师
        /// </summary>
        public virtual Lecturer? Lecturer { get; set; }

        /// <summary>
        /// 课程来源
        /// </summary>
        public EnumCourseSource Coursesource { get; set; }
        /// <summary>
        /// 课程来源
        /// </summary>
        public string? CoursesourceStr { get; set; }

        /// <summary>
        /// 时长（分钟）
        /// </summary>
        public double Duration { get; set; }

        /// <summary>
        /// 图片id
        /// </summary>
        public string? ImgId { get; set; }

        /// <summary>
        /// 视频id
        /// </summary>
        public string? VideosId { get; set; }

        /// <summary>
        /// 视频链接
        /// </summary>
        public string? VideosLink { get; set; }

        /// <summary>
        /// 是否启用
        /// true--启用
        /// </summary>
        public bool IsEnable { get; set; }

        /// <summary>
        /// 介绍
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 讲师介绍
        /// </summary>
        public string? LecturerDescription { get; set; }


        public override void ConfigureMapper(Profile profile)
        {
            profile.CreateMap<Course, MobileCourseModel>()
                .ForMember(d => d.Coursesource, options => options.MapFrom(s => (int)s.Coursesource))
                .ForMember(d => d.CoursesourceStr, options => options.MapFrom(s => EnumHelper.GetDescriptionContent(s.Coursesource)))
                .ForMember(d => d.CourseTypeStr, options => options.MapFrom(s => s.CourseType == null ? string.Empty : s.CourseType.Name))
                .ForMember(d => d.LecturerName, options => options.MapFrom(s => s.Lecturer == null ? string.Empty : s.Lecturer.Name))
                .ForMember(d => d.LecturerDescription, options => options.MapFrom(s => s.Lecturer == null ? string.Empty : s.Lecturer.Description));

            profile.CreateMap<MobileCourseModel, Course>();

        }
    }
}
